% This function takes a rental rate and spillovers and return the difference between the housing supply
% and housing demand. We search over the rental rate to find the one that sets supply equal to demand
function share_diff = find_rents_dyn(rs, Ss, lambdas, Prob)
    global pi_theta r_base myiter
   
    % Calculate choice probabiities
    [P_S, ~, ~, ~] = choiceProb(Ss, rs);

    % Calculate housing demand
    myDist0 = P_S .* Prob;
    myDist0  = sum(bsxfun(@times, myDist0 , reshape(pi_theta, [1,1,1,2])),4);
    H_dem = squeeze(sum(myDist0, 1:2));

    % Calculate housing supply
    tmp = housing_supply(rs, lambdas);

    % Calculate difference accounting for population growth of 1.0893
    share_diff = H_dem*(1.0893)^(myiter-1) - tmp;

end